import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'

const initState = {
    footerShow:false,
    slides: []
}
const reducer = (state = initState ,action)=>{
    const newState = JSON.parse(JSON.stringify(state))
    switch(action.type){
        case "SAVE_SLIDES" :
            newState.slides = action.data.map((item, key) => {
                return Object.assign({}, item, {key})
            })
            return newState
        case 'FSF':
            
            newState.footerShow=false
            return newState
        case 'FST':
            newState.footerShow=true
            return newState
        default:
            return newState
    }
}
const store = createStore(reducer, applyMiddleware(thunk))
export default store